package com.example.controller;

import com.example.common.Result;
import com.example.entity.Feedback;
import com.example.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author HY
 * @date 2025/2/9
 */
@RestController
@RequestMapping("/feedback")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;
    @GetMapping("/list")
    public Result list(Feedback feedback,
                       @RequestParam(defaultValue = "1") Integer pageNum,
                       @RequestParam(defaultValue = "10") Integer pageSize) {
        return Result.success(feedbackService.selectPage(feedback, pageNum, pageSize));
    }

    @GetMapping("/queryById/{id}")
    public Result queryById(@PathVariable Integer id) {
        return Result.success(feedbackService.selectById(id));
    }

    @PostMapping("/add")
    public Result add(@RequestBody Feedback feedback) {
        return feedbackService.add(feedback);
    }

    @PostMapping("/audit")
    public Result audit(@RequestBody Feedback feedback) {
        return feedbackService.audit(feedback);
    }
}
